package com.rjwh.dingdong.client.util;

import android.content.Context;
import android.util.TypedValue;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class UtilPublic {


    /**
     * ����Image���̳߳�
     */
    private static ExecutorService mImageThreadPool = null;

    /**
     * ��ȡ�̳߳صķ�������Ϊ�漰�����������⣬���Ǽ���ͬ����
     *
     * @return
     */
    public static ExecutorService getThreadPool() {
        if (mImageThreadPool == null) {
            synchronized (ExecutorService.class) {
                if (mImageThreadPool == null) {
                    // Ϊ������ͼƬ��ӵ���������������2���߳�������ͼƬ
                    mImageThreadPool = Executors.newFixedThreadPool(2);
                }
            }
        }

        return mImageThreadPool;

    }

    public static String getTimeStr() {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
        Date t = new Date(System.currentTimeMillis());
        String s = fmt.format(t);
        return s;
    }

    public static int dp2px(int dp, Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
                context.getResources().getDisplayMetrics());
    }
}

